import { createRouter, createWebHistory } from 'vue-router';
import Layout from '@/layouts'; // import UserLayout from '@/layouts/user-layout';

import UserLayout2 from '@/layouts/user-layout2';
import RouteView from '@/layouts/route-view';
export const routes = [
  {
    name: 'index',
    path: '/',
    component: Layout,
    redirect: '/articleManage/articleLibrary',
    children: [
      {
        name: 'home',
        path: '/home',
        redirect: '/home/main',
        component: RouteView,
        meta: {
          icon: 'icon-shouye-16px',
          title: '首页管理',
          hideChildrenInMenu: true,
        },
        children: [
          {
            name: 'home',
            path: '/home/main',
            meta: {
              title: '首页',
            },
            component: () => import('@/views/home'),
          },
        ],
      },
      {
        name: 'articleManage',
        path: '/articleManage',
        redirect: '/articleManage/articleLibrary',
        component: RouteView,
        meta: {
          icon: 'icon-wenzhangguanli-16px',
          title: '文章管理',
        },
        children: [
          {
            name: 'articleLibrary',
            path: '/articleManage/articleLibrary',
            meta: {
              title: '文章库',
            },
            component: () => import('@/views/articleManage/articleLibrary'),
          },
          {
            name: 'helpCenter',
            path: '/articleManage/menuHelp',
            meta: {
              title: '菜单帮助',
            },
            component: () => import('@/views/articleManage/menuHelp'),
          },
          {
            name: 'menuHelp',
            path: '/articleManage/helpCenter',
            meta: {
              title: '帮助中心',
            },
            component: () => import('@/views/articleManage/helpCenter'),
          },
          {
            name: 'notice',
            path: '/articleManage/notice',
            meta: {
              title: '公告',
            },
            component: () => import('@/views/articleManage/notice'),
          },
        ],
      },
      {
        name: 'marketSetting',
        path: '/marketSetting',
        redirect: '/marketSetting/inviteActive',
        component: RouteView,
        meta: {
          icon: 'icon-zonghoutai-yingxiao-16px',
          title: '营销设置',
        },
        children: [
          {
            name: 'inviteActive',
            path: '/marketSetting/inviteActive',
            meta: {
              title: '邀请码活动',
            },
            component: () => import('@/views/marketSetting/inviteActive'),
          },
          {
            name: 'codeLibrary',
            path: '/marketSetting/codeLibrary/:inviteId',
            meta: {
              title: '码库',
              hideInMenu: true,
            },
            component: () => import('@/views/marketSetting/codeLibrary'),
          },
        ],
      },
      {
        name: 'clientManage',
        path: '/clientManage',
        redirect: '/clientManage/storeManage',
        component: RouteView,
        meta: {
          title: '客户管理',
          icon: 'icon-zonghoutai-kehuguanli-16px',
        },
        children: [
          {
            name: 'storeManage',
            path: '/clientManage/storeManage',
            meta: {
              title: '店铺管理',
            },
            component: () => import('@/views/clientManage/storeManage'),
          },
          {
            name: 'accountManage',
            path: '/clientManage/accountManage',
            meta: {
              title: '账号管理',
              // isReload: true,
            },
            component: () => import('@/views/clientManage/accountManage'),
          },
        ],
      },
      {
        name: 'orderManage',
        path: '/orderManage',
        redirect: '/orderManage/order',
        component: RouteView,
        meta: {
          icon: 'icon-wenzhangguanli-16px',
          title: '订单管理',
        },
        children: [
          {
            name: 'orderDetail',
            path: '/orderManage/order',
            meta: {
              title: '订购订单',
            },
            component: () => import('@/views/orderManage/order'),
          },
        ]
      }
    ],
  },
];
export const staticRoutes = [
  {
    path: '/test',
    name: 'test',
    meta: {
      title: 'form.basicform.basic.title',
    },
    component: () => import('@/views/test'),
  },
  {
    path: '/user',
    name: 'user',
    meta: {
      hideInMenu: true,
      title: '',
    },
    component: UserLayout2,
    children: [
      {
        path: '/user/login',
        name: 'login',
        meta: {
          title: '登录',
        },
        component: () => import('@/views/user/login'),
      },
      {
        path: '/user/register',
        name: 'register',
        meta: {
          title: '注册',
        },
        component: () => import('@/views/user/register'),
      },
      {
        path: '/user/register-result',
        name: 'register-result',
        meta: {
          title: '注册账号',
        },
        component: () => import('@/views/user/register-result'),
      },
    ],
  },
  {
    path: '/:pathMatch(.*)',
    component: () => import('@/views/exception/404'),
  },
];
const router = createRouter({
  history: createWebHistory(),
  routes: staticRoutes,
});
export default router;
